<?php include('./templete/public/head.php') ?>
<body>
<hr class="bgcolor"/>
<!--发布金点子-->
<div class="fabu-main fabu-gonglue-main">
    <div class="main-content">
        <div class="c-list">
            <ul class="comm-table-view">
                <li class="table-view-cell">
                    <a>
                        <span class="title">标题</span>
                        <span class="line">|</span>
                        <span class="input"><input type="text" id="title"/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">地点</span>
                        <span class="line">|</span>
                        <span class="input">
                            <input type="text" name="place" id="place" value=""/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">站外链接</span>
                        <span class="line">|</span>
                        <span class="input">
                            <input type="text" name="link" id="link" value=""/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">分类选择</span>
                        <span class="line">|</span>
                        <select class="input" id="travel_faq_cate">
                            <option value="行程">行程</option>
                            <option value="住宿">住宿</option>
                            <option value="装束">装束</option>
                            <option value="购物">购物</option>
                            <option value="活动">活动</option>
                            <option value="交通">交通</option>
                            <option value="出入境">出入境</option>
                            <option value="实用信息">实用信息</option>
                            <option value="美食">美食</option>
                            <option value="通讯">通讯</option>
                            <option value="其他">其他</option>
                        </select>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell">
                    <a>
                        <span class="title">悬赏积分</span>
                        <span class="line">|</span>
                        <span class="input">
                            <input type="text" name="reward_integral" id="reward_integral" value=""/></span>
                        <span class="fr"><i class="iconfont icon-youjiantou"></i></span>
                    </a>
                </li>
                <li class="table-view-cell table-view-cell2">
                    <a>
                        <span>问题描述</span>
                        <div class="fabu-text">
                            <textarea id="content"></textarea>
                        </div>
                    </a>
                </li>
                <li class="table-view-cell table-view-cell2">
                    <button type="button" class="layui-btn" id="_img_upload" style="display: none">
                        <i class="layui-icon">&#xe67c;</i>上传图片
                    </button>
                    <a>
                        <span>相关图片</span>
                        <div class="fabu-upload">
                            <img src="_images/icon/upload.jpg" class="showPopover _img_show" onclick="add_img()"/>
                            <!--                            <img class="_img_show" class="showPopover" />-->
                        </div>
                    </a>
                    <input type="hidden" name="_img_url" id="_img_url" class="_img_url">
                </li>
            </ul>
            <div class="comm-btn comm-btn2 fabu-btn">
                <span class="color1 publish">发布</span>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function add_img() {
        document.getElementById('_img_upload').click();
    }

    $('.publish').click(function () {
        var title = $('#title').val();
        var place = $('#place').val();
        var reward_integral = $('#reward_integral').val();
        var content = $('#content').val();
        var img_url = $('#_img_url').val();
        var travel_faq_cate = $('#travel_faq_cate').val();
        var link = $('#link').val();
        if(isNaN(reward_integral)||reward_integral<1){
            layer.msg('悬赏积分请输入大于0的数字');
            return false;
        }
        if (!title) {
            layer.msg('请输入活动标题');
            return false;
        }
        if (!place) {
            layer.msg('请输入活动地点');
            return false;
        }
        if (!content) {
            layer.msg('请输入活动内容');
            return false;
        }
        layer.msg('请稍等');
        var loading = layer.load(1, {shade: [0.4, '#000']}); //0代表加载的风格，支持0-2
        $.ajax({
            url: "<?php echo url('publish_strategy') ?>",
            type: 'post',
            data: {
                title: title,
                place: place,
                reward_integral: reward_integral,
                content: content,
                img_url: img_url,
                link:link,
                travel_cate: travel_faq_cate,
                type:<?php echo $type?>
            },
            success: function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg);
                    setTimeout(function () {
                        location.href = res.url;
                    }, 1000);
                } else {
                    layer.msg(res.msg);
                }
                setTimeout(function () {
                    layer.closeAll();
                }, 1000);
            }
        })
    })

</script>
</html>